package com.lkd.handler;

import com.lkd.business.MsgHandler;
import com.lkd.config.TopicConfig;
import com.lkd.contract.SupplyContract;
import com.lkd.emq.Topic;
import com.lkd.service.VendingMachineService;
import com.lkd.utils.JsonUtil;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * 补货消息处理
 */
@Component
@Topic(TopicConfig.VMS_SUPPLY_TOPIC)
public class SupplyMsgTaskHandeler implements MsgHandler {

    @Resource
    private VendingMachineService vendingMachineService;

    @Override
    public void process(String jsonMsg) throws IOException {
        SupplyContract json = JsonUtil.getByJson(jsonMsg, SupplyContract.class);

        vendingMachineService.supply(json);
    }
}
